package org.gaming.fakecmd.util;

import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.Message;
import com.google.protobuf.util.JsonFormat;
import com.google.protobuf.util.JsonFormat.Printer;

public enum MessagePbPrinter {
    ;

    public static String msgToStr(Message message) {
        try {
            return jsonFormater.print(message);
        } catch (InvalidProtocolBufferException e) {
            throw new RuntimeException(e);
        }
    }

    private static final Printer jsonFormater = JsonFormat.printer().omittingInsignificantWhitespace();
}
